package com.budwk.app.util.poiUtils;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrFormatter;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.exception.ServiceException;
import com.budwk.app.sqfw.dto.FireHiddenExcelParamDaYingLuSQDTO;
import com.budwk.app.sqfw.enums.DaYingLuExcelType;
import com.budwk.app.sqfw.enums.DownLoadFileNameEnum;
import com.budwk.app.sqfw.models.Sqfw_formSummary;
import com.budwk.app.sys.models.Sys_user;
import com.budwk.app.sys.services.SysUserService;
import com.budwk.app.util.ClassUtil;
import com.budwk.app.util.StrUtil;
import com.budwk.app.util.poiUtils.excelPictureConfigBO.ExcelFileCreateParamBO;
import com.budwk.app.util.poiUtils.excelPictureConfigBO.FireHiddenExcelDaYingLuStreetBO;
import com.budwk.app.util.poiUtils.nutzBeanUtils.NutzIocUtils;
import com.budwk.starter.security.utils.SecurityUtil;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author ZY.Wang
 * @since 2023/9/26
 */
public class DaYingLuStreetFireHiddenExcelUtils {

    private static final String segSymbol = "#";

    private static final String downloadDateFormat = "yyyyMMddHHmm";

    private static final Set<String> bigPlaceInfoSet = Sets.newHashSet("大型商场、超市、酒店", "幼儿园、寄宿制学校、社会福利机构", "医院、诊所、卫生服务站", "劳动密集型企业、多业态混合经营场所", "其他重点消防安全场所");

    /**
     * 大营路街道消防安全excel
     *
     * @param excelParamDTO excel参数
     * @return excel链接
     */
    public static String createFireHiddenExcelDaYingLuSQ(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isTempData) {
        int fileIndex = excelParamDTO.getFileIndex();
        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();
        //zhangp 2023-11-27 下载模板放行
        if (StringUtils.isBlank(isTempData) || (StringUtils.isNotBlank(isTempData) && !"isTemplate-web".contains(isTempData))) {
            if (formSummaryList == null || formSummaryList.size() == 0) {
                return null;
            }
        }

        //生成安全隐患“三清单”表
        if (fileIndex == DaYingLuExcelType.THREE_DETAILED.getCode()) {
            return generateThreeDetail(excelParamDTO, isTempData);
        }

        //生成消防安全巡查检查台账表
        if (fileIndex == DaYingLuExcelType.INSPECTION_ON_PATROL.getCode()) {
            return generateInspectionOnPatrol(excelParamDTO, isTempData);
        }

        //生成“三合一”场所（含沿街门店）台账表
        if (fileIndex == DaYingLuExcelType.THREE_DAN_ONE_SITE.getCode()) {
            return threeDanOneSite(excelParamDTO, isTempData);
        }

        //生成消防安全重大风险隐患专项排查整治进度统计表
        if (fileIndex == DaYingLuExcelType.GREAT_RISK_HIDDEN.getCode()) {
            return greatRiskHidden(excelParamDTO, isTempData);
        }

        //生成餐饮行业使用燃气、燃料排查情况汇总表
        if (fileIndex == DaYingLuExcelType.CATERING_INDUSTRY.getCode()) {
            return cateringIndustry(excelParamDTO, isTempData);
        }

        // 生成小型生产场所台账
        if (fileIndex == DaYingLuExcelType.SMALL_BUSINESS_STANDING_BOOK.getCode()) {
            return smallBusinessStandingBook(excelParamDTO, isTempData);
        }

        // 生成附件1：云岩区燃气安全排查情况统计周报表
        if (fileIndex == DaYingLuExcelType.GAS_SAFETY_INS_STATISTICS_WEEKLY_REPORT.getCode()) {
            return gasSafetyInsStatisticWeeklyReport(excelParamDTO, isTempData);
        }

        // 生成附件3：夜摊燃气使用存储台账
        if (fileIndex == DaYingLuExcelType.NIGHT_STALL_GAS_STANDING_BOOK.getCode()) {
            return nightStallGasStandingBook(excelParamDTO, isTempData);
        }

        // 生成附件4：城镇燃气餐饮用户台账
        if (fileIndex == DaYingLuExcelType.URBAN_GAS_STANDING_BOOK.getCode()) {
            return urbanGasStandingBook(excelParamDTO, isTempData);
        }

        // 安全风险隐患排查整治台账
        if (fileIndex == DaYingLuExcelType.SAFETY_RISK_REC_STANDING_BOOK.getCode()) {
            return safetyRiskRecStandingBook(excelParamDTO, isTempData);
        }

        // 重点场所
        if (fileIndex == DaYingLuExcelType.KEY_LOCATIONS_STANDING_BOOK.getCode()) {
            return keyLocationsStandingBook(excelParamDTO, isTempData);
        }

        // 社会治安重点风险场所台账
        if (fileIndex == DaYingLuExcelType.PUBLIC_SECURITY_STANDING_BOOK.getCode()) {
            return DaYingLuStreetPublicSecurityExcelUtils.publicSecurityStandingBook(excelParamDTO, isTempData);
        }
        return null;
    }

    /**
     * 生成三清单
     */
    public static String generateThreeDetail(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        String unitName = excelParamDTO.getCompleteUnitName();
        String userName = excelParamDTO.getCreateUserName();
        String phone = excelParamDTO.getCreateUserPhone();
        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();
        try {
            Map<String, Object> threeDetailedParamMap = Maps.newHashMap();
            threeDetailedParamMap.put("unitName", unitName);
            threeDetailedParamMap.put("fillUserName", userName);
            threeDetailedParamMap.put("phone", phone);
            threeDetailedParamMap.put("fillUserNamePhone", userName + "-" + phone);
            threeDetailedParamMap.put("downloadDate", DateUtil.format(new Date(), downloadDateFormat));

            List<Map<String, Object>> dataList = Lists.newArrayList();

            int visAndInsNumIndex = 0;
            for (Sqfw_formSummary formSummary : formSummaryList) {

                String a24 = formSummary.getA24();
                if (!"旅馆".equals(formSummary.getA5()) ||
                        ("旅馆".equals(formSummary.getA5()) && !"无".equals(a24) && StringUtils.isNotBlank(a24))) {
                    StringBuilder a24RiskSB = new StringBuilder();
                    boolean excelGenerateFlag = judgeThreeDetailExcelGenerate(formSummary, a24RiskSB);
                    if (!excelGenerateFlag) continue;

                    //zhangp 2024-01-05 只要检测到一条数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }

                    visAndInsNumIndex++;
                    Map<String, Object> rollDataMap = Maps.newHashMap();
                    rollDataMap.put("a3", formSummary.getA3());
                    rollDataMap.put("a16", formSummary.getA16());
                    rollDataMap.put("num", visAndInsNumIndex);

                    rollDataMap.put("a24", a24RiskSB.toString());

                    String communityStr = "";
                    String community = formSummary.getCommunity();
                    if (StringUtils.isNotBlank(community)) communityStr = community.replace("社区", "居委会");
                    rollDataMap.put("communityStr", communityStr);

                    String a25DateStr = "";
                    String a25 = formSummary.getA25();
                    if (StringUtils.isNotBlank(a25)) {
                        a25DateStr = DateUtil.format(DateUtil.parse(a25, "yyyy-MM-dd"), "yyyy年MM月dd日");
                    }
                    rollDataMap.put("a25DateStr", a25DateStr);

                    String a9 = formSummary.getA9();
                    if (StringUtils.isBlank(a9)) a9 = formSummary.getA39();
                    List<byte[]> a9Bytes = CommonFormOfficeUtils.addPictureToByteList(a9, 1);
                    rollDataMap.put("a9", a9Bytes);

                    rollDataMap.put("a12", formSummary.getA12());

                    // 2023-10-10 14:28 临时处理一下 如果有整改后的图片，则是已当天整改。否则，填写a25减去检查时间的值
                    String a25Str = "";
                    boolean rectifyPicFlag = StringUtils.isNotBlank(formSummary.getA10()) || StringUtils.isNotBlank(formSummary.getA40());
                    boolean conditionByA61 = false;
                    String a61 = formSummary.getA61();
                    if (StringUtils.isBlank(a61)) a61 = JSONObject.toJSONString(Lists.newArrayList());
                    List<String> a61List = JSONObject.parseArray(a61, String.class);
                    if (a61List.size() > 5) {
                        String a61_6Str = a61List.get(5);
                        List<String> a61_6List = JSONObject.parseArray(a61_6Str, String.class);
                        if (a61_6List.size() > 0) {
                            conditionByA61 = true;
                        }

                        if (!conditionByA61) {
                            if (a61List.size() > 6) {
                                String a61_7Str = a61List.get(6);
                                List<String> a61_7List = JSONObject.parseArray(a61_7Str, String.class);
                                if (a61_7List.size() > 0) {
                                    conditionByA61 = true;
                                }
                            }
                        }
                    }
                    if (conditionByA61 && rectifyPicFlag) {
                        a25Str = "已当天整改";
                    } else if (StringUtils.isNotBlank(a25)) {
                        Date fillDate = formSummary.getFillDate();
                        if (fillDate == null) fillDate = new Date();
                        long betweenDay = DateUtil.betweenDay(DateUtil.parse(a25, "yyyy-MM-dd"), fillDate, true);
                        if (betweenDay == 0) a25Str = "已当天整改";
                        else a25Str = betweenDay + "天";
                    }
                    rollDataMap.put("a25", a25Str);

                    String a10 = formSummary.getA10();
                    if (StringUtils.isBlank(a10)) a10 = formSummary.getA40();
                    List<byte[]> a10Bytes = CommonFormOfficeUtils.addPictureToByteList(a10, 1);
                    rollDataMap.put("a10", a10Bytes);

                    rollDataMap.put("a1", formSummary.getA1());
                    rollDataMap.put("a2", formSummary.getA2());
                    rollDataMap.put("createUsername", formSummary.getCreateUserName());

                    String remark = "未整改";
                    if (StringUtils.isNotBlank(a10)) remark = "已整改";
                    rollDataMap.put("remark", remark);

                    dataList.add(rollDataMap);
                }

            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }
            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/threeDetailed.xlsx");
            String fileName = DownLoadFileNameEnum.DYL_THREE_DETAILED.getName();
            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(threeDetailedParamMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());
            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(StrFormatter.format("生成" + DaYingLuExcelType.THREE_DETAILED.getName() + "表错误"));
        }

        return null;
    }

    /**
     * 生成消防安全巡查检查台账表
     */
    public static String generateInspectionOnPatrol(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        try {
            List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();

            Map<String, Object> inspectionOnPatrolMap = Maps.newHashMap();
            inspectionOnPatrolMap.put("unitName", excelParamDTO.getCompleteUnitName());
            inspectionOnPatrolMap.put("street", excelParamDTO.getStreet());

            int visAndInsNumIndex = 0;
            List<Map<String, Object>> dataList = Lists.newArrayList();
            for (Sqfw_formSummary formSummary : formSummaryList) {
                String a24 = formSummary.getA24();
                if (!"旅馆".equals(formSummary.getA5()) ||
                        ("旅馆".equals(formSummary.getA5()) && !"无".equals(a24) && StringUtils.isNotBlank(a24))) {
                    String a5 = formSummary.getA5();
                    if (bigPlaceInfoSet.contains(a5)) continue;

                    Map<String, Object> rollDataMap = Maps.newHashMap();

                    rollDataMap.put("unitName", formSummary.getUnitName());
                    rollDataMap.put("a1", formSummary.getA1());
                    rollDataMap.put("a6", formSummary.getA6());
                    rollDataMap.put("a3", formSummary.getA3());
                    rollDataMap.put("a2", formSummary.getA2());
                    rollDataMap.put("a8", formSummary.getA8());
                    rollDataMap.put("a12", formSummary.getA12());

                    String a33 = formSummary.getA33();
                    String a36 = formSummary.getA36();
                    String a37 = formSummary.getA37();
                    String a44 = formSummary.getA44();
                    String a46 = formSummary.getA46();
                    String a47 = formSummary.getA47();
                    String a48 = formSummary.getA48();
                    String a49 = formSummary.getA49();
                    String a50 = formSummary.getA50();
                    String a7 = formSummary.getA7();
                    String a20 = formSummary.getA20();
                    StringBuilder stringBuilder = new StringBuilder();
                    if (!StringUtils.isBlank(a33) && !"旅馆".equals(formSummary.getA5()))
                        stringBuilder.append("三合一").append("\n");
                    if ("设置卷帘门、铁栅栏等".equals(a36)) stringBuilder.append(a36).append("\n");
                    if ("设置防盗窗等".equals(a37)) stringBuilder.append(a37).append("\n");
                    if ("0".equals(a44)) stringBuilder.append("没有灭火器").append("\n");
                    if (!"合格".equals(a46) && a46 != null) stringBuilder.append(a46).append("\n");
                    if (!"无".equals(a47) && a47 != null) stringBuilder.append(a47).append("\n");
                    if (!"否".equals(a48)) stringBuilder.append("使用明火、高温加热、取暖设备").append("\n");
                    if (!"否".equals(a49)) stringBuilder.append("存放有易燃易爆危险品").append("\n");
                    if ("是".equals(a50)) stringBuilder.append("黑酒精").append("\n");

                    if (a7 == null) a7 = "";
                    Set<String> a7Set = Sets.newHashSet(Splitter.on(",").split(a7));
                    if (a7Set.contains("使用醇基燃料")) stringBuilder.append("醇基燃料").append("\n");
                    if (StringUtils.isNotBlank(a20)) stringBuilder.append(a20.replace("无", ""));    // a20如果是无则不显示

                    String problemStr = stringBuilder.toString();
                    if (StringUtils.isBlank(problemStr) || problemStr.replace("\n", "").equals("无")) continue;

                    //zhangp 2024-01-05 只要检测到一条数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }

                    visAndInsNumIndex++;
                    rollDataMap.put("num", visAndInsNumIndex);

                    rollDataMap.put("problem", problemStr);

                    rollDataMap.put("a19", CommonFormOfficeUtils.addPictureToByteList(formSummary.getA19(), 1));
                    rollDataMap.put("fillDateStr", DateUtil.format(formSummary.getFillDate(), "yyyy-MM-dd HH:mm"));

                    dataList.add(rollDataMap);
                }

            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }
            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/inspectionOnPatrol.xlsx");
            String fileName = DownLoadFileNameEnum.DYL_INSPECTION_ON_PATROL.getName();
            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(inspectionOnPatrolMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setListNotLastRow(true);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());
            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(StrFormatter.format("生成" + DaYingLuExcelType.INSPECTION_ON_PATROL.getName() + "表错误"));
        }

        return null;
    }

    /**
     * 生成“三合一”场所（含沿街门店）台账表
     */
    public static String threeDanOneSite(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        try {
            List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();
            Map<String, Object> threeDanOneSiteMap = Maps.newHashMap();
            threeDanOneSiteMap.put("unitName", excelParamDTO.getCompleteUnitName());

            int visAndInsNumIndex = 0;
            List<Map<String, Object>> dataList = Lists.newArrayList();
            for (Sqfw_formSummary formSummary : formSummaryList) {
                String a33 = formSummary.getA33();
                String a5 = formSummary.getA5();
                String a68 = formSummary.getA68();//存储安全排查三合一状态：是、否
                // 12-18加的条件
                //if ((!"旅馆".equals(a5) && !"没有住人".equals(a33))) {
                // zhangp 2023-12-25 根据产品提供文档修改条件
                if ("是".equals(a68)) {
                    //zhangp 2023-12-25 三合一使用新字段判断
                    // a33没有问题的情况分两种 一种是第一次巡查时候没有住人传的值是空字符串
                    // 第二种是复查的时候没有住人传的值是“没有住人”
                   /* if (StringUtils.isBlank(a33)) {
                        continue;
                    }*/

                    // 大型场所不出现在三合一中
                    if (bigPlaceInfoSet.contains(a5)) continue;

                    //zhangp 2024-01-05 只要检测到一条数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }

                    Map<String, Object> rollDataMap = Maps.newHashMap();
                    visAndInsNumIndex++;

                    rollDataMap.put("num", visAndInsNumIndex);
                    rollDataMap.put("street", formSummary.getCounty());
                    rollDataMap.put("a1", formSummary.getA1());
                    rollDataMap.put("a5", formSummary.getA5());
                    rollDataMap.put("a3", formSummary.getA3());
                    rollDataMap.put("a2", formSummary.getA2());
                    rollDataMap.put("a8", formSummary.getA8());
                    rollDataMap.put("a11", formSummary.getA11());
                    rollDataMap.put("a34", formSummary.getA34());

                    //if (a33.equals("没有住人")) a33 = "住人已整改";
                    //zhangp 2023-12-25 由于使用了a68来判断是否进入三合一，因此此字段可能为空，会报空指针
                    if ("没有住人".equals(a33)) a33 = "住人已整改";
                    rollDataMap.put("a33", a33);

                    String communityStr = "";
                    String community = formSummary.getCommunity();
                    if (StringUtils.isNotBlank(community)) communityStr = community.replace("社区", "居委会");
                    rollDataMap.put("communityStr", communityStr);

                    String a25DateStr = "";
                    String a25 = formSummary.getA25();
                    if (StringUtils.isNotBlank(a25)) {
                        a25DateStr = DateUtil.format(DateUtil.parse(a25, "yyyy-MM-dd"), "yyyy年MM月dd日");
                    }
                    rollDataMap.put("a25DateStr", a25DateStr);

                    // 2023-10-10 14：38 临时处理 整改情况如果有整改图片则已整改 如果没有整改图片则未整改
                    boolean recPicFlag = StringUtils.isNotBlank(formSummary.getA40());
                    String a26Str = "";
                    //zhangp 2024-01-03 如果是没有住人则该字段为空
                    if (StringUtils.isNotBlank(a33)) {
                        if (recPicFlag) a26Str = "已整改";
                        else a26Str = "未整改";
                    }
                    rollDataMap.put("a26", a26Str);

                    String a25Str = "";
                    if (recPicFlag) a25Str = "已当天整改";
                    else if (StringUtils.isNotBlank(formSummary.getA25())) {
                        Date fillDate = formSummary.getFillDate();
                        if (fillDate == null) fillDate = new Date();
                        long a25BetweenDay = DateUtil.betweenDay(DateUtil.parse(formSummary.getA25(), "yyyy-MM-dd"), fillDate, true);
                        // wzy 2023-12-4 当天变为已当天整改
                        if (a25BetweenDay == 0) a25Str = "已当天整改";
                        else a25Str = a25BetweenDay + "天";
                    }
                    rollDataMap.put("a25", a25Str);

                    //图片处理
                    List<byte[]> a39Bytes = CommonFormOfficeUtils.addPictureToByteList(formSummary.getA39(), 1);
                    rollDataMap.put("a39", a39Bytes);

                    //List<byte[]> a40Bytes = CommonFormOfficeUtils.addPictureToByteList(formSummary.getA40(), 1);
                    List<byte[]> a40Bytes = Lists.newArrayList();
                    //zhangp 2024-01-03 如果是没有住人则取走访图片，如果有住人则取整改图片
                    if (StringUtils.isNotBlank(a33)) {
                        a40Bytes = CommonFormOfficeUtils.addPictureToByteList(formSummary.getA40(), 1);
                    } else {
                        a40Bytes = CommonFormOfficeUtils.addPictureToByteList(formSummary.getA67(), 1);
                    }
                    rollDataMap.put("a40", a40Bytes);

                    dataList.add(rollDataMap);
                }
            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }

            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/threeAndOneSite.xlsx");
            String fileName = DownLoadFileNameEnum.DYL_THREE_DAN_ONE_SITE.getName();
            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(threeDanOneSiteMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());
            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(StrFormatter.format("生成" + DaYingLuExcelType.THREE_DAN_ONE_SITE.getName() + "表错误"));
        }

        return null;
    }

    /**
     * 生成消防安全重大风险隐患专项整治进度统计表
     */
    public static String greatRiskHidden(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        try {
            List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();
            Map<String, Object> greatRiskHiddenParamMap = Maps.newHashMap();

            int a33Total = 0;
            int a26TTotal = 0;
            int a26FTotal = 0;
            int a40Total = 0;

            //zhangp 2024-01-05 检查是否能生成数据时使用,由于for循环里所有数据都能写入，因此代码提到for之前来做检测（优化）
            // 如果for循环里面增加判断此处代码需要放到for后面执行
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (!formSummaryList.isEmpty()) {
                    return "true";
                } else {
                    return "false";
                }
            }


            Set<String> a59Set = Sets.newHashSet(); // 出动人员名称set
            for (Sqfw_formSummary sqfwFormSummary : formSummaryList) {
                String a24 = sqfwFormSummary.getA24();
                String a18 = sqfwFormSummary.getA18();
                if (StringUtils.isNotBlank(a18)) {
                    a59Set.addAll(Sets.newHashSet(Splitter.on(",").split(a18)));
                }

                // a33 字段表示的意思为是否住人 现在这个字段必有值，默认值为"没有住人"
                //String a33 = sqfwFormSummary.getA33();
                a33Total++;
                // if (StringUtils.isNotBlank(a33) && !a33.equals("没有住人") && StringUtils.isNotBlank(a24)) a26FTotal++;
                // wzy 2023-11-30 临时修改取消a24判断
                if (!"无".equals(a24) && StringUtils.isNotBlank(a24)) a26FTotal++;

                // String a26 = sqfwFormSummary.getA26();
                // if (StringUtils.isNotBlank(a33) && !a33.equals("没有住人") && "已整改".equals(a26)) a26TTotal++;

                // wzy 2023-11-1 a26TTotal 使用a40不为空进行统计
                if (StringUtils.isNotBlank(sqfwFormSummary.getA40())) a26TTotal++;


                if (StringUtils.isNotBlank(sqfwFormSummary.getA40())) a40Total++;
            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
           /* if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (!formSummaryList.isEmpty()) {
                    return "true";
                } else {
                    return "false";
                }
            }*/
            List<Map<String, Object>> mapList = new ArrayList<>();
            Map<String, Object> map = new HashMap<>();

            a59Set.remove("");
            map.put("a59Total", a59Set.size());

            map.put("a33Total", a33Total);
            map.put("a26TTotal", a26TTotal);
            map.put("a26FTotal", a26FTotal);
            map.put("a40Total", a40Total);
            //zhangp 2023-12-05 当是模板下载时赋空值
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.contains("isTemplate")) {
                map.put("a59Total", null);
                map.put("a33Total", null);
                map.put("a26TTotal", null);
                map.put("a26FTotal", null);
                map.put("a40Total", null);
            }
            mapList.add(map);

            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/greatRiskHidden.xlsx");
            String fileName = DownLoadFileNameEnum.DYL_GREAT_RISK_HIDDEN.getName();
            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(greatRiskHiddenParamMap);
            excelFileCreateParam.setDataList(mapList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());
            excelFileCreateParam.setListNotLastRow(true);
            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(StrFormatter.format("生成" + DaYingLuExcelType.GREAT_RISK_HIDDEN.getName() + "表错误"));
        }

        return null;
    }

    /**
     * 生成餐饮行业使用燃气、燃料排查情况汇总表
     */
    public static String cateringIndustry(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        Map<String, Object> cateringIndustryParamMap = Maps.newHashMap();
        List<Map<String, Object>> dataList = Lists.newArrayList();

        cateringIndustryParamMap.put("unitName", excelParamDTO.getCompleteUnitName());
        cateringIndustryParamMap.put("fillUserNamePhone", excelParamDTO.getCreateUserName() + " " + excelParamDTO.getCreateUserPhone());
        cateringIndustryParamMap.put("downloadDate", DateUtil.format(new Date(), downloadDateFormat));

        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();

        try {
            int num = 0;
            for (Sqfw_formSummary formSummary : formSummaryList) {

                Map<String, Object> rollDataMap = Maps.newHashMap();

                // 大场所不生成
                String a5 = formSummary.getA5();
                if (bigPlaceInfoSet.contains(a5)) continue;

                //燃气使用情况(无、使用醇基燃料、瓶装液化气、瓶装天然气、瓶装二甲醚、用电)
                String a7 = formSummary.getA7();
                if (StringUtils.isBlank(a7)) a7 = "";

                //燃料使用情况(甲醇、乙醇、丙醇、丁烷、柴油、白油、黄油、植物油、环保油、用电、其他燃料)
                String a15 = formSummary.getA15();
                if (StringUtils.isBlank(a15)) a15 = "";
                if (a7.equals("无") || a7.equals("用炭")) continue;

                //zhangp 2024-01-05 只要检测到一条数据就返回
                if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                    return "true";
                }

                num++;
                rollDataMap.put("num", num);
                String street = formSummary.getCounty();
                if (StringUtils.isBlank(street)) street = "-";
                rollDataMap.put("unitNameStreet", formSummary.getUnitName() + "，" + street);
                rollDataMap.put("a1", formSummary.getA1());
                rollDataMap.put("a3", formSummary.getA3());
                rollDataMap.put("a2a8", formSummary.getA2() + " " + formSummary.getA8());
                String a55 = formSummary.getA55();

                String a55_1 = "否";
                String a55_2 = "0";
                String a55_3 = "否";

                if (StringUtils.isNotBlank(a55)) {
                    List<String> a55List = Lists.newArrayList(Splitter.on(segSymbol).split(a55));
                    a55_2 = a55List.get(0);
                    a55_3 = a55List.get(1);

                    if (!a55_2.equals("0")) a55_1 = "是";
                }
                rollDataMap.put("a55_1", a55_1);
                rollDataMap.put("a55_2", a55_2);
                rollDataMap.put("a55_3", a55_3);

                List<String> a7List = Lists.newArrayList(Splitter.on(",").split(a7));
                List<String> a15List = Lists.newArrayList(Splitter.on(",").split(a15));

                List<Integer> a7NumList = Lists.newArrayList();
                List<Integer> a15NumList = Lists.newArrayList();

                for (String str : a7List) {
                    if (str.equals("瓶装液化气")) a7NumList.add(1);
                    if (str.equals("瓶装天然气")) a7NumList.add(2);
                    if (str.equals("瓶装二甲醚")) a7NumList.add(3);
                    if (str.equals("用电")) a7NumList.add(4);
                    if (str.equals("管道燃气")) a7NumList.add(5);
                }
                a7NumList = a7NumList.stream().sorted().collect(Collectors.toList());
                String a7NumStr = Joiner.on("、").join(a7NumList);
                rollDataMap.put("a7Num", a7NumStr);

                for (String str : a15List) {
                    if (str.equals("甲醇")) a15NumList.add(1);
                    if (str.equals("乙醇")) a15NumList.add(2);
                    if (str.equals("丙醇")) a15NumList.add(3);
                    if (str.equals("丁烷")) a15NumList.add(4);
                    if (str.equals("柴油")) a15NumList.add(5);
                    if (str.equals("白油")) a15NumList.add(6);
                    if (str.equals("黄油")) a15NumList.add(7);
                    if (str.equals("植物油")) a15NumList.add(8);
                    if (str.equals("环保油")) a15NumList.add(9);
                    if (str.equals("用电")) a15NumList.add(10);
                    if (str.equals("其他燃油")) a15NumList.add(11);
                }
                a15NumList = a15NumList.stream().sorted().collect(Collectors.toList());

                String a15NumStr = Joiner.on("、").join(a15NumList);
                rollDataMap.put("a15Num", a15NumStr);

                List<byte[]> a56Bytes = CommonFormOfficeUtils.addPictureToByteList(formSummary.getA56(), 1);
                rollDataMap.put("a56", a56Bytes);

                String a57 = formSummary.getA57();
                String a57_1 = "";
                String a57_2 = "";
                if (StringUtils.isNotBlank(a57)) {
                    List<String> a57List = Lists.newArrayList(Splitter.on(segSymbol).split(a57));
                    a57_1 = a57List.get(0);
                    a57_2 = a57List.get(1);
                }
                rollDataMap.put("a57_1", a57_1);
                rollDataMap.put("a57_2", a57_2);
                String a6 = formSummary.getA6();
                rollDataMap.put(ClassUtil.getField(Sqfw_formSummary::getA6), "自建房".equals(a6) ? "是" : "否");
                String a30 = formSummary.getA30();
                a30 = StringUtils.isBlank(a30) ? "0" : a30;
                String a11 = formSummary.getA11();
                a11 = StringUtils.isBlank(a11) ? "-" : a11;
                rollDataMap.put("a30a11", a30 + "、" + a11);

                rollDataMap.put("a58", formSummary.getA58());

                rollDataMap.put("remark", null);

                dataList.add(rollDataMap);

            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }
            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/cateringIndustry.xlsx");
            String fileName = DownLoadFileNameEnum.DYL_CATERING_INDUSTRY.getName();
            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(cateringIndustryParamMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(StrFormatter.format("生成" + DaYingLuExcelType.CATERING_INDUSTRY.getName() + "表错误"));
        }

        return null;
    }

    /**
     * 生成小型生产场所台账
     */
    public static String smallBusinessStandingBook(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        try {
            List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();

            Map<String, Object> smallBusinessStandingBookParam = Maps.newHashMap();
            smallBusinessStandingBookParam.put("area", excelParamDTO.getArea());
            smallBusinessStandingBookParam.put("street", excelParamDTO.getStreet());
            smallBusinessStandingBookParam.put("downloadYear", DateUtil.year(new Date()));
            smallBusinessStandingBookParam.put("downloadMonth", DateUtil.month(new Date()) + 1);
            smallBusinessStandingBookParam.put("downloadDay", DateUtil.dayOfMonth(new Date()));
            //zhangp 2024-01-04 当是web模板下载时表头定死
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isTemplate-web")) {
                smallBusinessStandingBookParam.put("area", "云岩区");
                smallBusinessStandingBookParam.put("street", "大营路街道");
            }
            List<Map<String, Object>> dataList = Lists.newArrayList();

            SysUserService sysUserService = NutzIocUtils.getBean(SysUserService.class);
            for (Sqfw_formSummary formSummary : formSummaryList) {

                // wzy 2023-11-23 有数据就生成excel
                //String a7 = formSummary.getA7();
                //if (StringUtils.isNotBlank(a7)) {
                //    if (a7.equals("无") || a7.equals("用电")) continue;
                //}

                String a5 = formSummary.getA5();
                if (bigPlaceInfoSet.contains(a5)) continue;

                //zhangp 2024-01-05 只要检测到一条数据就返回
                if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                    return "true";
                }

                Map<String, Object> rollData = Maps.newHashMap();
                rollData.put("num", dataList.size() + 1);
                rollData.put("a1", formSummary.getA1());
                rollData.put("a4", formSummary.getA4());

                String city = formSummary.getCity();
                if (StringUtils.isBlank(city)) city = "";
                String area = formSummary.getDistrict();
                if (StringUtils.isBlank(area)) area = "";
                String cityArea = city + "、" + area;
                if (StringUtils.isBlank(city) && StringUtils.isBlank(area)) cityArea = "--";
                rollData.put("cityArea", cityArea);

                String street = formSummary.getCounty();
                String community = formSummary.getCommunity();
                if (StringUtils.isBlank(street)) street = "";
                if (StringUtils.isBlank(community)) community = "";
                String streetCommunity = street + "、" + community;
                if (StringUtils.isBlank(street) && StringUtils.isBlank(community)) streetCommunity = "--";
                rollData.put("streetCommunity", streetCommunity);

                rollData.put("a3", formSummary.getA3());
                rollData.put("a16", formSummary.getA16());
                rollData.put("a51", formSummary.getA51());
                rollData.put("a2", formSummary.getA2());
                rollData.put("a8", formSummary.getA8());

                String a52 = formSummary.getA52();
                if (StringUtils.isBlank(a5)) a5 = "-";
                if (StringUtils.isBlank(a52)) a52 = "-";
                rollData.put("a5A52", a5 + "/" + a52);

                List<String> mainRiskList = Lists.newArrayList();
                String a7 = formSummary.getA7();
                if (StringUtils.isBlank(a7)) a7 = "";
                Set<String> a7Set = Sets.newHashSet(Splitter.on(",").split(a7));
                if (a7Set.contains("瓶装液化气") || a7Set.contains("瓶装天然气") || a7Set.contains("瓶装二甲醚")) {
                    mainRiskList.add("气瓶使用");
                }
                if (a7Set.contains("使用醇基燃料")) {
                    mainRiskList.add("火灾");
                }
                if (a7Set.contains("用电")) {
                    mainRiskList.add("电气伤害");
                }
                if (a7Set.contains("用炭")) {
                    mainRiskList.add("使用火炭");
                }

                String mainRisk = Joiner.on("/").join(mainRiskList);
                rollData.put("mainRisk", mainRisk);

                rollData.put("remark", "");

                rollData.put("fillDate", DateUtil.format(formSummary.getFillDate(), DatePattern.NORM_DATE_PATTERN));
                rollData.put("fillImage", CommonFormOfficeUtils.addPictureToByteList(formSummary.getA67(), 1));

                // 居委会负责人
                rollData.put("committeePerson", StrUtil.formatStr(formSummary.getCreateUserName()));
                // 检查责任人签字
                List<byte[]> signatureUrlImage = new ArrayList<>();
                if (StringUtils.isNotEmpty(formSummary.getCreateBy())) {
                    Sys_user user = sysUserService.fetch(formSummary.getCreateBy());
                    String signatureUrl = user.getSignatureUrl();
                    if (StringUtils.isNotEmpty(signatureUrl)) {
                        signatureUrlImage = CommonFormOfficeUtils.addPictureToByteList(signatureUrl, 1);
                    }
                }
                rollData.put("signatureUrlImage", signatureUrlImage);
                dataList.add(rollData);

            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }

            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/smallBusinessPremisesStandingBook.xlsx");
            String fileName = DownLoadFileNameEnum.DYL_SMALL_BUSINESS_STANDING_BOOK.getName();
            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(smallBusinessStandingBookParam);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());
            excelFileCreateParam.setListNotLastRow(true);

            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(StrFormatter.format("生成小型生产场所台账失败，请联系管理员"));
        }

        return null;
    }

    /**
     * 生成附件1：云岩区燃气安全排查情况统计周报表
     */
    public static String gasSafetyInsStatisticWeeklyReport(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();


        //zhangp 2024-01-05 检查是否能生成数据时使用,由于for循环里所有数据都能写入，因此代码提到for之前来做检测（优化）
        // 如果for循环里面增加判断此处代码需要放到for后面执行
        if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
            if (!formSummaryList.isEmpty()) {
                return "true";
            } else {
                return "false";
            }
        }

        Set<String> a7Filter = Sets.newHashSet("用电", "无", "用炭");
        List<Sqfw_formSummary> newFormSummaryList = Lists.newArrayList();
        for (Sqfw_formSummary formSummary : formSummaryList) {
            String a7 = formSummary.getA7();
            if (StringUtils.isNotBlank(a7)) {
                Set<String> a7Set = Sets.newHashSet(Splitter.on(",").split(a7));
                a7Set.remove("");
                a7Set.removeAll(a7Filter);
                if (a7Set.size() > 0) {
                    newFormSummaryList.add(formSummary);
                }
            }
        }
        formSummaryList = newFormSummaryList;

        // 如果是后台web应用，则重新统计组次数量 add by LJT 2023-12-08
        int groupNum = 1;
        if (CommonFormOfficeForAdminUtils.APPLICATION_ADMIN.equals(excelParamDTO.getDataSource())) {
            groupNum = formSummaryList.stream().collect(Collectors.groupingBy(Sqfw_formSummary::getSqfwId, HashMap::new, Collectors.toList())).size();
        }
        try {
            Map<String, Object> gasWeeklyReportParamMap = Maps.newHashMap();
            gasWeeklyReportParamMap.put("areaLevel", excelParamDTO.getArea());
            gasWeeklyReportParamMap.put("unitName", excelParamDTO.getCompleteUnitName());
            gasWeeklyReportParamMap.put("downloadDate", DateUtil.format(new Date(), downloadDateFormat));
            gasWeeklyReportParamMap.put("createUsernamePhone", excelParamDTO.getCreateUserName() + " " + excelParamDTO.getCreateUserPhone());
            //zhangp 2024-01-04 当是web模板下载时表头定死
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isTemplate-web")) {
                gasWeeklyReportParamMap.put("areaLevel", "云岩区");
            }
            // 这个附件一次任务生成一条数据 所以基本上这个地方生成的就是一条数据
            List<Map<String, Object>> dataList = Lists.newArrayList();
            int a59Count = 0;
            int a17BigCount = 0, a17General = 0;
            int a17GeneralRectified = 0, a17BigRectified = 0;

            int a17TodayCount = 0, a17TodayGeneral = 0, a17TodayBig = 0;
            for (Sqfw_formSummary formSummary : formSummaryList) {
                // 检查人数统计
                try {
                    int a59Int = Integer.parseInt(formSummary.getA59());
                    a59Count += a59Int;
                } catch (Exception ignored) {
                }

                String a17 = formSummary.getA17();
                String a27 = formSummary.getA27();
                if (StringUtils.isBlank(a17)) a17 = "";
                if (StringUtils.isBlank(a27)) a27 = "";

                if (a17.equals("一般")) {
                    a17General++;
                    if (a27.equals("已整改")) a17GeneralRectified++;
                }
                if (a17.equals("重大")) {
                    a17BigCount++;
                    if (a27.equals("已整改")) a17BigRectified++;
                }

                // 2023-11-1 当日隐患需要重新计算
                Date fillDate = formSummary.getFillDate();
                if (DateUtil.betweenDay(fillDate, new Date(), true) == 0) {
                    a17TodayCount++;
                    if (a17.equals("一般")) a17TodayGeneral++;
                    if (a17.equals("重大")) a17TodayBig++;
                }
            }

            Map<String, Object> dataMap = Maps.newHashMap();
            dataMap.put("street", excelParamDTO.getStreet());
            dataMap.put("checkCount", groupNum);   // 这个地方是app里面生成的，一个任务就是一个检查组次，所以固定为1
            dataMap.put("a59Count", a59Count);
            dataMap.put("a1Count", formSummaryList.size());
            dataMap.put("a17Count", formSummaryList.size());
            dataMap.put("a17Big", a17BigCount);
            dataMap.put("a17General", a17General);
            dataMap.put("a17GeneralRectified", a17GeneralRectified);
            dataMap.put("a17BigRectified", a17BigRectified);

            // 今日隐患
            dataMap.put("a17TodayCount", a17TodayCount);
            dataMap.put("a17TodayGeneral", a17TodayGeneral);
            dataMap.put("a17TodayBig", a17TodayBig);

            //zhangp 2023-12-05 模板下载时赋空值
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.contains("isTemplate")) {
                dataMap.put("checkCount", 0);
            }
            dataList.add(dataMap);

            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/gasSafetyInsStatisticsWeeklyReport.xlsx");
            //String fileName = "燃气安全排查情况统计周报表";
            String fileName = DownLoadFileNameEnum.DYL_GAS_SAFETY_INS_STATISTICS_WEEKLY_REPORT.getName();

            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(gasWeeklyReportParamMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(StrFormatter.format("生成附件1：云岩区燃气安全排查情况统计周报表失败"));
        }

        return null;
    }

    /**
     * 夜摊燃气使用存储台账
     */
    public static String nightStallGasStandingBook(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {

        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();

        try {
            Map<String, Object> nightStallGasParamMap = Maps.newHashMap();
            nightStallGasParamMap.put("street", excelParamDTO.getStreet());
            nightStallGasParamMap.put("downloadDateStr", DateUtil.format(new Date(), downloadDateFormat));
            nightStallGasParamMap.put("unitName", excelParamDTO.getCompleteUnitName());
            nightStallGasParamMap.put("createUsernameAndPhone", excelParamDTO.getCreateUserName() + " " + excelParamDTO.getCreateUserPhone());
            if ("isTemplate-web".equals(isCheckData)) {
                nightStallGasParamMap.put("street", "大营路街道");
            }
            List<Map<String, Object>> dataList = Lists.newArrayList();
            int rollIndex = 0;
            for (Sqfw_formSummary formSummary : formSummaryList) {
                String a7 = formSummary.getA7();
                String a13 = formSummary.getA13();
                //zhangp 2023-12-06 空判断否则会报空指针
                if (StringUtils.isBlank(a7)) {
                    continue;
                }
                Set<String> a7Set = Sets.newHashSet(a7.split(","));
                if ((a7Set.contains("瓶装液化气") || a7Set.contains("瓶装天然气")
                        || a7Set.contains("瓶装二甲醚") || a7Set.contains("管道燃气")
                        || a7Set.contains("使用醇基燃料"))
                        && StringUtils.isNotBlank(a13) && a13.equals("是")) {

                    //zhangp 2024-01-05 只要检测到一条数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }

                    rollIndex++;
                    Map<String, Object> rollDataMap = Maps.newHashMap();
                    rollDataMap.put("num", rollIndex);
                    rollDataMap.put("a1", formSummary.getA1());
                    rollDataMap.put("a3", formSummary.getA3());
                    rollDataMap.put("a14", formSummary.getA14());
                    rollDataMap.put("a54", formSummary.getA54());
                    rollDataMap.put("a53", formSummary.getA53());

                    String a4 = formSummary.getA4();
                    String a4Str = StringUtils.isBlank(a4) ? "无执照" : "有执照";
                    rollDataMap.put("a4Str", a4Str);

                    String a23Str = "";
                    String a23 = formSummary.getA23();
                    if (StringUtils.isNotBlank(a23)) {
                        List<String> a23List = Lists.newArrayList(a23.split(","));
                        if (a23List.size() > 0)
                            a23Str = a23List.get(a23List.size() - 1);
                    }
                    rollDataMap.put("a23Str", a23Str);

                    String a61 = formSummary.getA61();
                    String a60 = formSummary.getA60();
                    if (StringUtils.isBlank(a60)) a60 = JSONObject.toJSONString(Lists.newArrayList());
                    if (StringUtils.isBlank(a61)) a61 = JSONObject.toJSONString(Lists.newArrayList());
                    String a61_1Str = "燃气周边，存储周边整洁";
                    String tempA61_1Str = "";
                    List<String> a60List = JSONObject.parseArray(a60, String.class);
                    List<String> a61List = JSONObject.parseArray(a61, String.class);
                    if (a60List.size() > 0) {
                        String a60_1 = a60List.get(0);
                        if (StringUtils.isNotBlank(a60_1)) {
                            List<String> a60_1List = JSONObject.parseArray(a60_1, String.class);
                            tempA61_1Str = Joiner.on("、").join(a60_1List);
                        }
                    }
                    if (a61List.size() > 0) {
                        String a61_1 = a61List.get(0);
                        if (StringUtils.isNotBlank(a61_1)) {
                            List<String> a61_1List = JSONObject.parseArray(a61_1, String.class);
                            if (StringUtils.isNotBlank(tempA61_1Str)) {
                                tempA61_1Str = tempA61_1Str + "，" + Joiner.on("、").join(a61_1List);
                            } else {
                                tempA61_1Str = Joiner.on("、").join(a61_1List);
                            }
                        }
                    }
                    if (StringUtils.isNotBlank(tempA61_1Str))
                        a61_1Str = tempA61_1Str;
                    rollDataMap.put("a61_1Str", a61_1Str);

                    String a61_2Str = "灶具等燃气暂无异常";
                    String tempA61_2Str = "";
                    if (a60List.size() > 0) {
                        String a60_2 = a60List.get(1);
                        if (StringUtils.isNotBlank(a60_2)) {
                            List<String> a60_2List = JSONObject.parseArray(a60_2, String.class);
                            tempA61_2Str = Joiner.on("、").join(a60_2List);
                        }
                    }
                    if (a61List.size() > 0) {
                        String a61_2 = a61List.get(1);
                        if (StringUtils.isNotBlank(a61_2)) {
                            List<String> a61_2List = JSONObject.parseArray(a61_2, String.class);
                            if (StringUtils.isNotBlank(tempA61_2Str)) {
                                tempA61_2Str = tempA61_2Str + "，" + Joiner.on("、").join(a61_2List);
                            } else {
                                tempA61_2Str = Joiner.on("、").join(a61_2List);
                            }
                        }
                    }
                    if (StringUtils.isNotBlank(tempA61_2Str))
                        a61_2Str = tempA61_2Str;
                    rollDataMap.put("a61_2Str", a61_2Str);

                    String a61_3Str = "暂无异常";
                    if (a60List.size() > 3) {
                        String a60_3 = a60List.get(2);
                        List<String> a60_3List = JSONObject.parseArray(a60_3, String.class);
                        if (a60_3List.size() > 0) a61_3Str = "有异常";
                    }
                    if (a61List.size() > 3) {
                        String a61_3 = a61List.get(2);
                        List<String> a61_3List = JSONObject.parseArray(a61_3, String.class);
                        if (a61_3List.size() > 0) a61_3Str = "有异常";
                    }
                    rollDataMap.put("a61_3Str", a61_3Str);

                    String a61Str = "暂无异常";
                    for (String a61Item : a61List) {
                        List<String> a61ItemList = JSONObject.parseArray(a61Item, String.class);
                        if (a61ItemList.size() > 0) {
                            a61Str = "有异常";
                            break;
                        }
                    }
                    for (String a60Item : a60List) {
                        List<String> a60ItemList = JSONObject.parseArray(a60Item, String.class);
                        if (a60ItemList.size() > 0) {
                            a61Str = "有异常";
                            break;
                        }
                    }
                    rollDataMap.put("a61Str", a61Str);

                    rollDataMap.put("a27", formSummary.getA27());
                    rollDataMap.put("a2", formSummary.getA2());
                    rollDataMap.put("a8", formSummary.getA8());

                    dataList.add(rollDataMap);

                }

            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }
            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/nightStallGasStandingBook.xlsx");
            //String fileName = "夜摊燃气使用情况台账";
            String fileName = DownLoadFileNameEnum.DYL_NIGHT_STALL_GAS_STANDING_BOOK.getName();
            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(nightStallGasParamMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException(StrFormatter.format("夜摊燃气使用存储台账失败"));
        }
    }

    /**
     * 生成附件4：城镇燃气餐饮用户台账
     */
    public static String urbanGasStandingBook(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {

        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();

        try {
            Map<String, Object> urbanGasParamMap = Maps.newHashMap();
            urbanGasParamMap.put("street", excelParamDTO.getStreet());
            urbanGasParamMap.put("unitName", excelParamDTO.getCompleteUnitName());
            urbanGasParamMap.put("createUsernamePhone", excelParamDTO.getCreateUserName() + " " + excelParamDTO.getCreateUserPhone());
            urbanGasParamMap.put("downloadData", DateUtil.format(new Date(), downloadDateFormat));
            if ("isTemplate-web".equals(isCheckData)) {
                urbanGasParamMap.put("street", "大营路街道");
            }
            List<Map<String, Object>> dataList = Lists.newArrayList();

            int rollIndex = 0;
            for (Sqfw_formSummary formSummary : formSummaryList) {
                String a7 = formSummary.getA7();
                String a13 = formSummary.getA13();
                //zhangp 2023-12-06 空判断否则会报空指针
                if (StringUtils.isBlank(a7)) {
                    continue;
                }
                Set<String> a7Set = Sets.newHashSet(a7.split(","));
                if ((a7Set.contains("瓶装液化气") || a7Set.contains("瓶装天然气") || a7Set.contains("瓶装二甲醚")
                        || a7Set.contains("管道燃气") || a7Set.contains("使用醇基燃料"))
                        && StringUtils.isNotBlank(a13) && a13.equals("否")) {

                    //zhangp 2024-01-05 只要检测到一条数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }

                    rollIndex++;
                    Map<String, Object> rollDataMap = Maps.newHashMap();
                    rollDataMap.put("num", rollIndex);
                    rollDataMap.put("a1", formSummary.getA1());
                    rollDataMap.put("a3", formSummary.getA3());
                    rollDataMap.put("a7", formSummary.getA7());
                    rollDataMap.put("a14", formSummary.getA14());
                    rollDataMap.put("a54", formSummary.getA54());
                    rollDataMap.put("a53", formSummary.getA53());

                    String a4 = formSummary.getA4();
                    String a4Str = StringUtils.isBlank(a4) ? "无执照" : "有执照";
                    rollDataMap.put("a4Str", a4Str);

                    // wzy 2023-10-31 也需要根据a61进行判断
                    String a61 = formSummary.getA61();
                    String a60 = formSummary.getA60();
                    if (StringUtils.isBlank(a60)) a60 = JSONObject.toJSONString(Lists.newArrayList());
                    if (StringUtils.isBlank(a61)) a61 = JSONObject.toJSONString(Lists.newArrayList());
                    String a61_1Str = "燃气周边，存储周边整洁";
                    String tempA61_1Str = "";
                    List<String> a60List = JSONObject.parseArray(a60, String.class);
                    List<String> a61List = JSONObject.parseArray(a61, String.class);
                    if (a60List.size() > 0) {
                        String a60_1 = a60List.get(0);
                        if (StringUtils.isNotBlank(a60_1)) {
                            List<String> a60_1List = JSONObject.parseArray(a60_1, String.class);
                            tempA61_1Str = Joiner.on("、").join(a60_1List);
                        }
                    }
                    if (a61List.size() > 0) {
                        String a61_1 = a61List.get(0);
                        if (StringUtils.isNotBlank(a61_1)) {
                            List<String> a61_1List = JSONObject.parseArray(a61_1, String.class);
                            if (StringUtils.isNotBlank(tempA61_1Str)) {
                                tempA61_1Str = tempA61_1Str + "，" + Joiner.on("、").join(a61_1List);
                            } else {
                                tempA61_1Str = Joiner.on("、").join(a61_1List);
                            }
                        }
                    }
                    if (StringUtils.isNotBlank(tempA61_1Str))
                        a61_1Str = tempA61_1Str;
                    rollDataMap.put("a61_1Str", a61_1Str);

                    String a23Str = "";
                    String a23 = formSummary.getA23();
                    if (StringUtils.isNotBlank(a23)) {
                        List<String> a23List = Lists.newArrayList(a23.split(","));
                        if (a23List.size() > 0)
                            a23Str = a23List.get(a23List.size() - 1);
                    }
                    rollDataMap.put("a23Str", a23Str);

                    String a61_2Str = "灶具等燃气暂无异常";
                    String tempA61_2Str = "";
                    if (a60List.size() > 0) {
                        String a60_2 = a60List.get(1);
                        if (StringUtils.isNotBlank(a60_2)) {
                            List<String> a60_2List = JSONObject.parseArray(a60_2, String.class);
                            tempA61_2Str = Joiner.on("、").join(a60_2List);
                        }
                    }
                    if (a61List.size() > 0) {
                        String a61_2 = a61List.get(1);
                        if (StringUtils.isNotBlank(a61_2)) {
                            List<String> a61_2List = JSONObject.parseArray(a61_2, String.class);
                            if (StringUtils.isNotBlank(tempA61_2Str)) {
                                tempA61_2Str = tempA61_2Str + "，" + Joiner.on("、").join(a61_2List);
                            } else {
                                tempA61_2Str = Joiner.on("、").join(a61_2List);
                            }
                        }
                    }
                    if (StringUtils.isNotBlank(tempA61_2Str))
                        a61_2Str = tempA61_2Str;
                    rollDataMap.put("a61_2Str", a61_2Str);

                    String a61_3Str = "暂无异常";
                    if (a60List.size() > 3) {
                        String a60_3 = a60List.get(2);
                        List<String> a60_3List = JSONObject.parseArray(a60_3, String.class);
                        if (a60_3List.size() > 0) a61_3Str = "有异常";
                    }
                    if (a61List.size() > 3) {
                        String a61_3 = a61List.get(2);
                        List<String> a61_3List = JSONObject.parseArray(a61_3, String.class);
                        if (a61_3List.size() > 0) a61_3Str = "有异常";
                    }
                    rollDataMap.put("a61_3Str", a61_3Str);

                    String a61Str = "暂无异常";
                    for (String a61Item : a61List) {
                        List<String> a61ItemList = JSONObject.parseArray(a61Item, String.class);
                        if (a61ItemList.size() > 0) {
                            a61Str = "有异常";
                            break;
                        }
                    }
                    for (String a60Item : a60List) {
                        List<String> a60ItemList = JSONObject.parseArray(a60Item, String.class);
                        if (a60ItemList.size() > 0) {
                            a61Str = "有异常";
                            break;
                        }
                    }
                    rollDataMap.put("a61Str", a61Str);

                    rollDataMap.put("a27", formSummary.getA27());
                    rollDataMap.put("a2", formSummary.getA2());
                    rollDataMap.put("a8", formSummary.getA8());

                    dataList.add(rollDataMap);

                }
            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }
            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/urbanGasStandingBook.xlsx");
            //String fileName = "城镇燃气餐饮用户台账表燃气台账表";
            String fileName = DownLoadFileNameEnum.DYL_URBAN_GAS_STANDING_BOOK.getName();

            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(urbanGasParamMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException("生成城镇燃气餐饮用户台账失败");
        }
    }

    /**
     * 安全风险隐患排查台账
     */
    public static String safetyRiskRecStandingBook(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();
        try {
            Map<String, Object> safetyRiskRecParamMap = Maps.newHashMap();

            List<Map<String, Object>> dataList = Lists.newArrayList();
            int numIndex = 0;
            for (Sqfw_formSummary formSummary : formSummaryList) {
                Map<String, Object> dataMap = Maps.newHashMap();

                String a5 = formSummary.getA5();
                if (!bigPlaceInfoSet.contains(a5)) continue;

                //zhangp 2024-01-05 只要检测到一条数据就返回
                if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                    return "true";
                }

                numIndex++;
                dataMap.put("num", numIndex);
                dataMap.put("a63", formSummary.getA63());
                dataMap.put("a1", formSummary.getA1());
                dataMap.put("a3", formSummary.getA3());
                dataMap.put("a2A8", formSummary.getA2() + "：" + formSummary.getA8());

                String a64 = formSummary.getA64();
                if (StringUtils.isNotBlank(a64)) {
                    List<String> a64List = JSONObject.parseArray(a64, String.class);
                    String a64_1Str = a64List.get(0);
                    if (StringUtils.isNotBlank(a64_1Str)) {
                        List<String> a64_1List = JSONObject.parseArray(a64_1Str, String.class);
                        for (int index = 0; index < a64_1List.size(); index++) {
                            String keyName = "a64_1_" + (index + 1);
                            String keyValue = a64_1List.get(index);
                            dataMap.put(keyName, keyValue);
                        }
                    }
                }

                dataMap.put("a20", formSummary.getA20());
                dataMap.put("a12", formSummary.getA12());

                String a25Str = "无";
                String a25 = formSummary.getA25();
                if (StringUtils.isNotBlank(a25)) {
                    DateTime a25Date = DateUtil.parse(a25, "yyyy-MM-dd");
                    long betweenDay = DateUtil.betweenDay(formSummary.getFillDate(), a25Date, true);
                    if (betweenDay == 0) a25Str = "当天";
                    else a25Str = betweenDay + "天";
                }
                dataMap.put("a25Str", a25Str);

                dataMap.put("a65", formSummary.getA65());

                dataList.add(dataMap);
            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }
            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/safetyRiskRecStandingBook.xlsx");
            //String fileName = "消防安全风险隐患排查整治台账";
            String fileName = DownLoadFileNameEnum.DYL_SAFETY_RISK_REC_STANDING_BOOK.getName();

            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(safetyRiskRecParamMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException("生成安全风险隐患排查台账失败");
        }
    }


    /**
     * 重点场所台账
     */
    public static String keyLocationsStandingBook(FireHiddenExcelParamDaYingLuSQDTO excelParamDTO, String isCheckData) {
        try {
            Map<String, Object> keyLocationRecParamMap = Maps.newHashMap();
            keyLocationRecParamMap.put("downloadDateStr", DateUtil.format(new Date(), "yyyy-MM-dd"));


            List<Map<String, Object>> dataList = Lists.newArrayList();
            int numIndex = 0;

            for (Sqfw_formSummary formSummary : excelParamDTO.getFormSummaryList()) {
                String a5 = formSummary.getA5();
                // 只有重点场所的数据才会生成表格
                if (StringUtils.isNotBlank(a5) && bigPlaceInfoSet.contains(a5)) {

                    //zhangp 2024-01-05 只要检测到一条数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }

                    numIndex++;
                    Map<String, Object> rowDataMap = Maps.newHashMap();
                    rowDataMap.put("num", numIndex);
                    rowDataMap.put("a1", formSummary.getA1());
                    rowDataMap.put("district", formSummary.getDistrict());
                    rowDataMap.put("a63", formSummary.getA63());

                    rowDataMap.put("a2", formSummary.getA2());
                    rowDataMap.put("a8", formSummary.getA8());
                    rowDataMap.put("a12", formSummary.getA12());

                    StringBuilder riskSB = new StringBuilder();

                    String a64 = formSummary.getA64();
                    if (StringUtils.isNotBlank(a64)) {
                        List<String> a64JsonList = JSONObject.parseArray(a64, String.class);
                        if (a64JsonList.size() > 1) {
                            String a64_2JsonStr = a64JsonList.get(1);
                            List<String> a64_2List = JSONObject.parseArray(a64_2JsonStr, String.class);
                            String a64_2ContentStr = Joiner.on(",").join(a64_2List);
                            if (StringUtils.isNotBlank(a64_2ContentStr)) riskSB.append(a64_2ContentStr).append("\n");
                        }

                        if (a64JsonList.size() > 2) {
                            String a64_3JsonStr = a64JsonList.get(2);
                            List<String> a64_3List = JSONObject.parseArray(a64_3JsonStr, String.class);
                            String a64_3ContentStr = Joiner.on(",").join(a64_3List);
                            if (StringUtils.isNotBlank(a64_3ContentStr)) riskSB.append(a64_3ContentStr).append("\n");
                        }
                    }
                    String a20 = formSummary.getA20();
                    if (StringUtils.isNotBlank(a20) && !a20.equals("无")) {
                        riskSB.append(a20);
                    }
                    if (StringUtils.isBlank(riskSB.toString())) {
                        riskSB.append("无");
                    }
                    rowDataMap.put("safetyRisk", riskSB.toString());

                    String rectificationStatus = "";
                    if (StringUtils.isNotBlank(a64)) {
                        List<String> a64JsonList = JSONObject.parseArray(a64, String.class);

                        if (a64JsonList.size() > 2) {
                            String a64_3JsonStr = a64JsonList.get(2);
                            List<String> a64_3List = JSONObject.parseArray(a64_3JsonStr, String.class);
                            if (a64_3List.size() > 0) {
                                rectificationStatus = "整改中";
                            } else if (StringUtils.isBlank(a20) || a20.equals("无")) {
                                rectificationStatus = "已整改";
                            } else {
                                Map<String, Sqfw_formSummary> lastCheckMap = excelParamDTO.getLastFormSummaryCheckMap();
                                Sqfw_formSummary lastFormSummary = lastCheckMap.get(formSummary.getId());
                                if (lastFormSummary != null) {
                                    String lastCheckA64 = lastFormSummary.getA64();
                                    if (StringUtils.isNotBlank(lastCheckA64)) {
                                        List<String> lastA64JsonList = JSONObject.parseArray(lastCheckA64, String.class);
                                        if (lastA64JsonList.size() > 2) {
                                            String lastA64_2JsonStr = lastA64JsonList.get(1);
                                            if (StringUtils.isNotBlank(lastA64_2JsonStr)) {
                                                List<String> lastA64_2List = JSONObject.parseArray(lastA64_2JsonStr, String.class);
                                                if (lastA64_2List.size() > 0) {
                                                    rectificationStatus = "已整改";
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // wzy 2023-12-8 临时处理如果safetyRisk为无的时候 是否整改为空字符串
                    String safetyRisk = riskSB.toString().replace("\n", "");
                    if (StringUtils.isBlank(safetyRisk) || safetyRisk.equals("无")) rectificationStatus = "";

                    rowDataMap.put("recStatus", rectificationStatus);
                    dataList.add(rowDataMap);

                }
            }
            //zhangp 2023-12-04 检查是否能生成数据时使用
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                if (dataList.isEmpty()) {
                    return "false";
                }
            }
            String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("daYingLu/keyLocationStandingBook.xlsx");
            //String fileName = "云岩区消防安全重大风险隐患台账";
            String fileName = DownLoadFileNameEnum.DYL_KEY_LOCATIONS_STANDING_BOOK.getName();

            if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                fileName += excelParamDTO.getFileNameSuffix();

            ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
            excelFileCreateParam.setTemplatePath(templatePath);
            excelFileCreateParam.setSheetParam(keyLocationRecParamMap);
            excelFileCreateParam.setDataList(dataList);
            excelFileCreateParam.setClazz(FireHiddenExcelDaYingLuStreetBO.class);
            excelFileCreateParam.setFileName(fileName);
            excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());
            excelFileCreateParam.setListNotLastRow(true);

            return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException("生成重点场所台账失败");
        }
    }
    //--------------------------------------------------------------------------------------------


    /**
     * 判断是否生成三清单数据
     */
    public static boolean judgeThreeDetailExcelGenerate(Sqfw_formSummary formSummary, StringBuilder a24RiskInfoSB) {
        // wzy 2023-11-23 如果a24有值时生成表格
        // 如果a60第四个数组或者第五个数组有值生成表格
        // 如果a61第四个数组或者第五个数组有值生成表格
        boolean a24GenerateFlag = false;

        String a24 = formSummary.getA24();  // a24表示含有隐患的消防安全问题
        String a60 = formSummary.getA60();
        String a61 = formSummary.getA61();

        if (StringUtils.isNotBlank(a24)) {
            a24GenerateFlag = true;
            a24RiskInfoSB.append(a24).append("\n");
        }

        // 2023-12-20 a24和a60的问题有重复，所以先屏蔽掉a60
        //boolean a60GenerateFlag = threeDetailGenerateExcelFlagA60OrA61Judge(a60, a24RiskInfoSB);
        boolean a61GenerateFlag = threeDetailGenerateExcelFlagA60OrA61Judge(a61, a24RiskInfoSB);

        //return (a24GenerateFlag || a60GenerateFlag || a61GenerateFlag);
        return (a24GenerateFlag || a61GenerateFlag);
    }

    /**
     * 根据a60和a61判断是否生成三清单数据
     */
    private static boolean threeDetailGenerateExcelFlagA60OrA61Judge(String field, StringBuilder a24RiskInfoSB) {
        boolean generateExcelFlag = false;
        if (StringUtils.isBlank(field)) field = JSONObject.toJSONString(Lists.newArrayList());
        List<String> a60List = Lists.newArrayList(JSONObject.parseArray(field, String.class));
        if (a60List.size() > 3) {
            String a60_4JsonStr = a60List.get(3);
            try {
                List<String> a60_4List = JSONObject.parseArray(a60_4JsonStr, String.class);
                if (a60_4List.size() > 0) {
                    generateExcelFlag = true;
                    a24RiskInfoSB.append(Joiner.on(",").join(a60_4List)).append("\n");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if (a60List.size() > 4) {
            String a60_5JsonStr = a60List.get(4);
            try {
                List<String> a60_5List = JSONObject.parseArray(a60_5JsonStr, String.class);
                if (a60_5List.size() > 0) {
                    generateExcelFlag = true;
                    a24RiskInfoSB.append(Joiner.on(",").join(a60_5List)).append("\n");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return generateExcelFlag;
    }
}
